#pragma once

#include "../common/BasePclModel.h"
#include "includeBase.h"

class CylinderSegmentationModel : public BasePclModel
{
public:
    CylinderSegmentationModel();

public:
    static CylinderSegmentationModel& get();

public: // IJsonSerializable
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    QJsonObject toJson() const override;

public: // Property
    QString pcdFile() const { return pcdFile_; }
    void setPcdFile(const QString& pcdFile) { pcdFile_ = pcdFile; }

    QString filterFieldName() const { return filterFieldName_; }
    void setFilterFieldName(const QString& filterFieldName) { filterFieldName_ = filterFieldName; }

    double filterLimitsMin() const { return filterLimitsMin_; }
    void setFilterLimitsMin(double filterLimitsMin) { filterLimitsMin_ = filterLimitsMin; }

    double filterLimitsMax() const { return filterLimitsMax_; }
    void setFilterLimitsMax(double filterLimitsMax) { filterLimitsMax_ = filterLimitsMax; }

    int neKSearch() const { return neKSearch_; }
    void setNeKSearch(int neKSearch) { neKSearch_ = neKSearch; }

    double planeNormalDistanceWeight() const { return planeNormalDistanceWeight_; }
    void setPlaneNormalDistanceWeight(double planeNormalDistanceWeight)
    {
        planeNormalDistanceWeight_ = planeNormalDistanceWeight;
    }

    int planeMaxIterations() const { return planeMaxIterations_; }
    void setPlaneMaxIterations(int planeMaxIterations) { planeMaxIterations_ = planeMaxIterations; }

    double planeDistanceThreshold() const { return planeDistanceThreshold_; }
    void setPlaneDistanceThreshold(double planeDistanceThreshold) { planeDistanceThreshold_ = planeDistanceThreshold; }

    double cylinderNormalDistanceWeight() const { return cylinderNormalDistanceWeight_; }
    void setCylinderNormalDistanceWeight(double cylinderNormalDistanceWeight)
    {
        cylinderNormalDistanceWeight_ = cylinderNormalDistanceWeight;
    }

    int cylinderMaxIterations() const { return cylinderMaxIterations_; }
    void setCylinderMaxIterations(int cylinderMaxIterations) { cylinderMaxIterations_ = cylinderMaxIterations; }

    double cylinderDistanceThreshold() const { return cylinderDistanceThreshold_; }
    void setCylinderDistanceThreshold(double cylinderDistanceThreshold)
    {
        cylinderDistanceThreshold_ = cylinderDistanceThreshold;
    }

    double cylinderRadiusMin() const { return cylinderRadiusMin_; }
    void setCylinderRadiusMin(double cylinderRadiusMin) { cylinderRadiusMin_ = cylinderRadiusMin; }

    double cylinderRadiusMax() const { return cylinderRadiusMax_; }
    void setCylinderRadiusMax(double cylinderRadiusMax) { cylinderRadiusMax_ = cylinderRadiusMax; }

private:
    QString pcdFile_ = "<pcl-data>/tutorials/table_scene_mug_stereo_textured.pcd";

    QString filterFieldName_ = "z";
    double filterLimitsMin_ = 0.0;
    double filterLimitsMax_ = 1.5;
    int neKSearch_ = 50;
    double planeNormalDistanceWeight_ = 0.1;
    int planeMaxIterations_ = 100;
    double planeDistanceThreshold_ = 0.03;

    double cylinderNormalDistanceWeight_ = 0.1;
    int cylinderMaxIterations_ = 10000;
    double cylinderDistanceThreshold_ = 0.05;
    double cylinderRadiusMin_ = 0;
    double cylinderRadiusMax_ = 0.1;
};
